package com.jushu.storbox.database;

import java.util.HashMap;
import java.util.List;

import android.content.Context;

import com.jushu.storbox.entities.FileFolderInfo;
import com.jushu.storbox.entities.FolderInfo;
import com.huawei.sharedrive.sdk.android.modelV2.response.FolderResponse;

public interface IFolderDao extends IBaseDao {
	
	public final static String TABLE_NAME = "tb_folder_list";
	
	public final static String CURRENT_USER_ID = "current_user_jd";
	
	public final static String TABLE_COMMAND = "Create table " + TABLE_NAME + "("
			+ FIELD_ID + " integer," 
			+ id + " text," 
			+ owner_by + " text," 
			+ file_name + " text,"
			+ is_file + " integer," 
			+ parent_folder_id + " text,"
			+ file_size + " integer," 
			+ server_ctime + " integer,"
			+ server_mtime + " integer," 
			+ local_path + " text,"
			+ client_ctime + " integer," 
			+ client_mtime + " integer,"
			+ last_refresh_time + " integer," 
			+ content_sync_status + " integer,"
			+ static_status + " text," 
			+ trans_status + " integer," 
			+ trans_status_ref_cnt + " integer," 
			+ is_exist + " integer," 
			+ local_operation_time + " integer," 
			+ local_last_modify_time + " integer,"
			+ description + " text," 
			+ file_version + " text," 
			+ isshare + " text," 
			+ isshare_link + " text," 
			+ isencrypt + " text,"
			+ isSync + " integer," 
			+ fileIcon + " text," 
			+ changed_folderId + " char,"
			+ CURRENT_USER_ID +" text,"
			+"CONSTRAINT pk_tb_folder_list PRIMARY KEY ("+id+","+owner_by +","+CURRENT_USER_ID+")"
			+")";

	public FileFolderInfo insertFolder(FolderResponse folderResponse, int syncStu);

	public void insertFolder(FileFolderInfo folder);

	public void updateFolder(FolderResponse folderInfoResponse);

	public int updateFolder(FolderInfo folderInfo);

	public long insertOrUpdateFolder(FolderInfo folderInfo,
			Context context);

	public void insertOrUpdateFolder(FolderResponse folderInfo,
			Context context);

	public List<FolderInfo> getFolderList(String ownerId,
			String folderId);

	public HashMap<String, FolderInfo> getMappedFolderDatas(
			String ownerId, String folderId);

	// flag 0:my cloud page, 1: shared page
	public List<FolderInfo> getFolderListPage(String ownerId,
			String folderId, int flag);

	public List<FolderInfo> getFolderListByPage(int pageNo,
			int number, String ownerId, String folderId, String des,
			String orderBy);

	@Deprecated
	public List<FolderInfo> getFolderListPage(int flag,
			String ownerId, String folderId, String des, String orderBy);

	public void deleteFolder(String ownerId, String folderId);

	public FolderInfo getFolderById(FileFolderInfo folder);
	
	public FolderInfo getFolderById(String ownerId, String folderId);

	public void updateLocalPath(String ownerId, String folderId,
			String localPath);

	public void updateTransStatus(String ownerId, String folderId,
			int status);

	public void updateParent(String ownerId, String folderId,
			String parentId);

	public int updateSyncStatuc(String ownerId, String folderId,
			int syncStatus);

	public void updateLastRefreshTime(String ownerId, String folderId,
			long lastRefreshTime);

	public long getLastRefreshTime(String ownerId, String folderId);

	public long getLastUpdateTime(String ownerId, String folderId);

	public void updateLastUpdateTime(String ownerId, String folderId);

	/** update sync state</br>
	 * call {@link FileFolderInfo#setContentSyncState(int)} before this*/
	public void updateLocalSaveState(FileFolderInfo folderInfo);
	
	public void rename(String name, FolderResponse folderResponse,
			FileFolderInfo folder);

	public void rename(String name, FolderResponse folderResponse,
			String ownerId, String folderID);

	public void move(FileFolderInfo folder, FileFolderInfo targetFolder);

	public void move(String ownerId, String parentID, String folderID);

	public void deleteAll();

	public FolderInfo getFolderByName(FileFolderInfo folder,
			String folderName);

	public FolderInfo getFolderByName(String ownerId,
			String folderName);

	public List<FolderInfo> getSearchFolderList(
			FileFolderInfo folder, String fileName);

	public List<FolderInfo> getSearchFolderList(String ownerId,
			String fileName);

	public void setChangedFolderId(FileFolderInfo folder,
			String changeFolderId);

	public void setChangedFolderId(String ownerId, String folderId,
			String changeFolderId);

	public String getChangedFolderId(FileFolderInfo folder);

	public String getChangedFolderId(String ownerId, String folderId);

	public void setFolderLink(FileFolderInfo folder,
			boolean isShareLink);

	public void setFolderLink(String ownerId, String folderId,
			boolean isShareLink);

	public void cleanCatch();

	public FolderInfo getFolderById(FolderResponse frServer);

	public void updateSyncStatuc(FolderResponse frServer,
			int downloadStatusCacheDb);

	public void rename(FolderResponse folderResponse,
			FileFolderInfo fileInformation);

}